﻿using System;
using System.Windows;
using jSLApp.Client.ApplicationBase;
using jSLApp.Client.MainService;
using jSLCore.Client.Presentation.ApplicationContainer;
using jSLCore.Client.Presentation.BaseControl.Selection;

namespace jSLApp.Client.Controls
{
    public partial class ArticleGrid : jSLGrid
    {
        public ArticleGrid()
        {
            InitializeComponent();
            Style = (Style)Resources["selGrid"];
            ShowDetailsClicked+=OnShowDetailsClicked;
        }

        private void OnShowDetailsClicked(object sender, RowSelectedEventArgs rowSelectedEventArgs)
        {
            var ent = (New)rowSelectedEventArgs.RowObject;
            ((MainContentContainer)ApplicationContainer.CurrentContentContainer).GotoArticle(ent.id);
        }

        private void goto_Article(object sender, RoutedEventArgs e)
        {

            var element = (FrameworkElement) sender;
            var ent = (New) element.DataContext;
            InvokeShowDetailsClicked(new RowSelectedEventArgs(ent));
            
        }
    }
}
